package cn.caplike.demo.repository.java;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;

/**
 * @author LiKe
 * @version 1.0.0
 * @date 2022-07-14 14:00
 */
public class AboutDouble {

    public static void main(String[] args) {
        final double up = 0.3 / 70.0;
        final double down = (70.0 - 0.3) / 70.0;

        System.out.println(up);
        System.out.println(down);

        System.out.println(new DecimalFormat("0.00%").format(BigDecimal.valueOf(up).setScale(4, RoundingMode.UP)));
        System.out.println(new DecimalFormat("0.00%").format(BigDecimal.valueOf(down).setScale(4, RoundingMode.DOWN)));
    }
}